home *** CD-ROM | disk | FTP | other *** search
-
-
- /*
- demonstrate bug of mathieeedoubbas.library 37.1
- */
-
- #include <stdio.h>
-
- #include <inline/mathieeedoubbas.h>
- #include <inline/exec.h>
-
- struct Library *MathIeeeDoubBasBase;
-
- union convert
- {
- double d;
- struct {
- unsigned int s:1;
- unsigned int e:11;
- unsigned int m1:20;
- unsigned int m2;
- } IEEE;
- };
-
- int main()
- {
- double d1, d2;
- union convert conv;
-
- MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 0);
- if(MathIeeeDoubBasBase == 0)
- {
- printf("could not open mathieeedoubbas.library\n");
- exit(1);
- }
-
- d1 = -10.0;
- conv.d = d1;
- conv.IEEE.m2++;
- d2 = conv.d;
-
-
- #define TEST(a,b,c) printf("%s: %d (should be %d)\n", a, b, c);
-
-
- printf("Show mathieeedoubbas.library 37.1 bug of IEEEDPCmp(d1,d2)\n\n");
- printf("d1 = %.17f, d2 = %.17f\n\n", d1, d2);
-
- TEST("d1 <d2", d1<d2 , 0);
- TEST("d1<=d2", d1<=d2, 0);
- TEST("d1 >d2", d1>d2 , 1);
- TEST("d1>=d2", d1>=d2, 1);
- printf("\n");
- TEST("d2 <d1", d2<d1 , 1);
- TEST("d2<=d1", d2<=d1, 1);
- TEST("d2 >d1", d2>d1 , 0);
- TEST("d2>=d1", d2>=d1, 0);
- printf("\n");
- TEST("IEEEDPCmp(d1,d2)", IEEEDPCmp(d1,d2), 1);
- TEST("IEEEDPCmp(d2,d1)", IEEEDPCmp(d2,d1), -1);
-
- CloseLibrary(MathIeeeDoubBasBase);
- }
-